<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../org/angular.min.js"></script>
</head>
<body>
    <div ng-app="vm" ng-controller="ctrl">
       <input type="text" ng-model="news.title">
       <span>{{error}}</span>
    </div>
    <script>
        var vm = angular.module('vm',[]);
        vm.controller('ctrl',['$scope',function($scope){
            $scope.news = {title:""};
           $scope.$watch('news',function(n,o){
               $scope.error = n.title.length>3?'长度不能超过3':'';
           },true)
        }])
    </script>
</body>
</html>